package com.MapTest;

import java.util.HashMap;
import java.util.function.BiConsumer;

public class MapTest2 {
    public static void main(String[] args) {
        //创建一个HashMap集合
        HashMap<Student,String> hm = new HashMap<>();

        //先创建3个学生对象
        Student s1 = new Student("zhangsan",29);
        Student s2 = new Student("lisi",28);
        Student s3 = new Student("wangwu",27);


        //存储3个键值对元素：
        hm.put(s1,"beijing");
        hm.put(s2,"shanghai");
        hm.put(s3,"guangzhou");

        //遍历：
        hm.forEach( (student, s) ->System.out.println
                (student.getName() +" " + student.getAge() +"----" + s));


    }
}
